{{extend "group_layout.html"}}

{{block group_menu}}
{{include "group_menu.html"}}
{{group_menu(group.name, current="document")}}
{{end}}

{{block group_content}}
{{
import os
from uliweb.contrib.upload import get_url
from uliweb.utils.files import str_filesize
}}
<div class="clearfix" style="margin-bottom:10px;">
    {{if has_role('group_member', request.user, group_name=group.name):}}
        <a class="more-link red" href="/group/{{=group.name}}/document/upload">Upload Document</a>
    {{pass}}
</div>
<div>
    <table border="0" cellspacing="10px" cellpadding="4px" class="table">
    <thead>
        <tr>
            <th width="5%">..</th><th width="56%">Filename</th><th width="12%">Date</th><th width="7%">Size</th><th width="20%">Actions</th>
        </tr>
    </thead>
    <tbody>
        {{for doc in documents:}}
            <tr>
                <td>..</td>
                <td><a href="/group/{{=group.name}}/document/{{=doc.id}}">{{=os.path.basename(doc.filename)}}</a></td>
                <td>{{=doc.create_time.strftime("%Y-%m-%d")}}</td>
                <td>{{=str_filesize(doc.size)}}</td>
                <td><a href="{{=get_url(doc.filename)}}?action=inline">View</a>
                <a href="{{=get_url(doc.filename)}}">Download</a>
                {{if has_role('group_member', request.user, group_name=group.name):}}
                <a href="/group/{{=group.name}}/document/{{=doc.id}}/delete">Delete</a>
                {{pass}}
                </td>
            </tr>
        {{pass}}
    </tbody>
    </table>
</div>
{{end}}

{{block group_sidebar}}
<div class="box">
    <h2>Categories</h2>
    <div class="tool">
        {{if has_role('group_member', request.user, group_name=group.name):}}
            <a href="/group/{{=group.name}}/document/new_category">New Category</a>
        {{pass}}
    </div>
    <div class="box-body">
        <ul class="common-list">
        <li><span><a href="/group/{{=group.name}}/document">All</a></span> <strong>{{=group.documents_count}}</strong></li>
        {{for c in group.categories.all():}}
            <li><span><a href="/group/{{=group.name}}/document/category/{{=c.id}}">{{=c.name}}</a></span> <strong>{{=c.documents_count}}</strong></li>
        {{pass}}
        </ul>
    </div>
</div>
<div class="box">
    <h2>Tags</h2>
    <div class="box-body">
    </div>
</div>
{{end}}
